import request from "@/utils/request";
import {
  commonList,
  commonAdd,
  commonDetail,
  commonEdit,
  commonBatchDelete,
} from "../_common";
const controller = "catalogue";
// 媒资下载排行
export function list(data) {
  return commonList(controller)(data);
}

/**
 * 添加记录
 * @param data 记录数据内容
 */
export function add(data) {
  return commonAdd(controller)(data);
}

/**
 * 获取记录详情
 * @param id 记录id
 */
export function detail(id) {
  return commonDetail(controller)(id);
}

/**
 * 编辑记录
 * @param id  记录id
 * @param data  修改数据
 */
export function edit(id, data) {
  return commonEdit(controller)(id, data);
}

/**
 * 批量删除
 * @param ids 要删除的数据id数组，[id1, id2, id3]
 */
export function batchDelete(ids) {
  return commonBatchDelete(controller)(ids);
}

// 编目信息复制
export function catalogueCopy(catalogueId) {
  return request({
    url: `/catalogue/copy/${catalogueId}`,
    method: "get",
  });
}

// 启用、禁用编目信息
export function catalogueStatusChange(catalogueId, dataStatus) {
  return request({
    url: `/catalogue/status/${catalogueId}/${dataStatus}`,
    method: "get",
  });
}

export function getCatalogueEnable() {
  return request({
    url: `/catalogue/enabled`,
    method: "get",
  });
}

// 媒资编目数据明细
export function getMediaCatalogue(mediaId) {
  return request({
    url: `/catalogueData/${mediaId}`,
    method: "get",
  });
}

// 媒资编目数据修改
export function editMediaCatalogue(mediaId, catalogueDataList) {
  return request({
    url: `/catalogueData/${mediaId}`,
    method: "put",
    data: catalogueDataList ,
  });
}
